﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace APPFrameworkStudy.DAL.SqlServer
{
    public class EFConfig
    {
        public EFConfig()
        {
            EFDbConfiguration config1 = new EFDbConfiguration();
            EFDbMigrationsConfiguration config2 = new EFDbMigrationsConfiguration();
        }
    }

    /// <summary>
    /// 代码优先配置
    /// </summary>
    public class EFDbConfiguration : DbConfiguration
    {
        public EFDbConfiguration()
        {
            //当模型改变，删除数据库重建
            SetDatabaseInitializer<OrderDataMapper>(new DropCreateDatabaseIfModelChanges<OrderDataMapper>());
        }
    }

    public class EFDbMigrationsConfiguration : DbMigrationsConfiguration
    {
        public EFDbMigrationsConfiguration()
        {
            //设置为false，Entity Framework就不能自动创建数据库。
            //AutomaticMigrationsEnabled = false;
        }
    }
}
